diff options
| author | Adam Soltys <[email protected]> | 2023-01-18 19:44:27 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2023-01-18 19:44:27 -0800 |
| commit | 0e0f39af2e6585d7b61cf67652cdc0c2b2f06eb8 (patch) | |
| tree | 85e0fb00f3aa89fdde1cbb667bf801564bff7610 /src/routes/(app)/pot/[name]/+page.server.js | |
| parent | 7de4b0d2cd330674dcd02d2b007c1477fd48caaa (diff) | |
| download | coinos-ui-0e0f39af2e6585d7b61cf67652cdc0c2b2f06eb8.tar.gz coinos-ui-0e0f39af2e6585d7b61cf67652cdc0c2b2f06eb8.zip | |
pots
Diffstat (limited to 'src/routes/(app)/pot/[name]/+page.server.js')
| -rw-r--r-- | src/routes/(app)/pot/[name]/+page.server.js | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/routes/(app)/pot/[name]/+page.server.js b/src/routes/(app)/pot/[name]/+page.server.js new file mode 100644 index 00000000..8f8b9d8f --- /dev/null +++ b/src/routes/(app)/pot/[name]/+page.server.js @@ -0,0 +1,23 @@ +import { error, redirect } from '@sveltejs/kit'; +import { auth, get, post } from '$lib/utils'; +import Qr from 'qrcode-base64'; + +export let load = async ({ params: { name }, url }) => { + let { amount, payments } = await get(`/pot/${name}`); + + let src = Qr.drawImg(url.href, { size: 300 }); + return { amount, payments, src }; +}; + +export const actions = { + default: async ({ cookies, locals, params, request }) => { + let { user } = locals; + + if (user) { + await post('/redeem', params, auth(cookies)); + throw redirect(307, `/${user.username}/payments`); + } + + throw redirect(307, '/register'); + } +}; |
